<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<!--兼容设置-->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="renderer" content="webkit" />
		<title>在线会商服务系统-登录</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<script src="../bootstrap3/jquery-1.9.1.min.js"></script>
	</head>
	<body>
		<header class="header" style="text-align: center">
			<span><small>欢迎访问</small><b>在线会商服务系统</b></span>
		</header>
		<div style="text-align: center">
			<div class="loginDiv">
				<p>用户登录</p>
				<form id="form-login" action="index.html" role="form">
					<div class="form-group">
						用户名：<input name="username" type="text" id="userName" placeholder="请输入用户名">
					</div>
					<div class="form-group">
						密码：<input name="password" type="text" id="password" placeholder="请输入密码">
					</div>
					<div class="checkbox">
						<input type="checkbox" id="auto">自动登录
					</div>
					<div class="form-group">
						<input id="btn-login" type="button" value="登录" />
					</div>
				</form>
			</div>
		</div>
		<script type="text/javascript">
			$("#btn-login").click(function() {
				$.ajax({
					url: "/users/login",
					type: "POST",
					data: $("#form-login").serialize(),
					dataType: "json",
					success: function(json) {
						if (json.state == 200) {
							alert("登录成功！");
							// $.cookie("avatar", json.data.avatar, {expires: 7});
							// console.log("cookie中的avatar=" + $.cookie("avatar"));
							location.href = "index.html";
						} else {
							alert("登录失败！" + json.message);
						}
					}
				});
			});
		</script>
	</body>
</html>